import {ColumnsType} from "antd/es/table";
import {Badge, Space} from "antd";
import {Link} from "react-router-dom";
import {ellipsisHandler, getMethodTag} from "util/ColumnsUtil";
import {SecurityPath} from "type/SecurityPath";

const pathColumns: ColumnsType<SecurityPath> = [
    {
        dataIndex: 'index',
        title: '序号' ,
        width: 60,
        align: "center" ,
        render: (value, record, index) => {
            return  <strong> {index + 1} </strong> ;
        }
    },
    {
        key: 'id',
        dataIndex: 'id' ,
        title: '路径编号',
        width: 110,
        align: "center" ,
        ellipsis: {showTitle: false},
        render: (value,record) => <Link to={"./details"} state={record}>{value}</Link>
    },
    {
        key: 'pattern',
        dataIndex: 'pattern' ,
        title: '路径模式',
        ellipsis: {showTitle: false},
        render: ellipsisHandler
    },
    {
        key: 'explain',
        dataIndex: 'explain' ,
        title: '路径说明',
        width: 150,
        // align: "center" ,
        ellipsis: {showTitle: false},
        render: ellipsisHandler
    },
    {
        key: 'method',
        dataIndex: 'method' ,
        title: '请求方法',
        width: 90,
        align: "center" ,
        render: getMethodTag
    },
    {
        key: 'last',
        dataIndex: 'last' ,
        title: '子节点',
        width: 80,
        render: (value) => <Badge status={ value ? "success" : "error"} text={ value ? "Yes" : "No" } />
    },
    {
        key: 'order',
        dataIndex: 'order' ,
        title: '数据排序',
        width: 100,
        align: "center" ,
    },
    {
        key: 'remark',
        dataIndex: 'remark' ,
        title: '备注信息',
        // width: 100,
        align: "center" ,
        ellipsis: {showTitle: false},
        render: ellipsisHandler
    },
    {
        key: 'option',
        title: '路径操作',
        dataIndex: 'option' ,
        align: "center",
        width: 170,
        render: (_, record) => {
            return (
                <Space size={12}>
                    <Link key={"role-update"} to={'./update/' + record.id}>更新</Link>
                    <Link style={{color: 'red'}} key={"role-delete"} state={record} to={"./delete"}>删除</Link>
                </Space>
            );
        }
    }
] ;
export default pathColumns ;
